# Load Necessary Packages
library(glmnet)
library(foreign)
library(estimatr)
library(dplyr)
library(tidyr)
library(bcf)
library(dbarts)
library(texreg)
library(Hmisc)
library(grid)
library(gridExtra)
library(interplot)
library(margins)
library(car)
library(plotrix)
library(ggpubr)
library(effectsize)
library(MASS)
library(rms)
library(pwr)
library(DeclareDesign)
library(estimatr)
library(haven)
library(TOSTER)
library(stargazer)

# Load Data
setwd("/users/josephphillips/Dropbox/COVID-19/Data/")
data <- read.dta("US_pooled_complete_v12.dta")

# Load glmnet function
run_LASSO <- function(data, yvar){
  
  set.seed(2334)
  
  var_quo <- enquo(yvar)
  
  ## select x variables 
  dat <- data %>%
    dplyr::select(college, agegroup, male, married, frequent_church, region, pid3, ideo7, high_incidence,crt, knowledge,nonwhite, polinterest,health_trust,media_trust)
  
  ## select y-variable
  out1 <- data %>% 
    dplyr::select(!!var_quo) %>% pull() # save as a vector instead of a data-frame to use model.matrix()
  
  merged1 <- cbind(out1, dat) %>% na.omit() ## merge and delete NA
  x1 <- model.matrix(out1 ~ ., data = merged1) ## make model matrix
  y1 <- merged1$out1 ## select y-variable from NA-deleted dataset
  mod1 <- cv.glmnet(x1, y1, alpha = 1, family = "gaussian") ## run lasso model
  coef <- coef(mod1) ## get coef  
  
  list(merged1, x1, y1, mod1, coef)
  
}


# Clean Controls
data$male <- as.numeric(data$male) -1
data$married <- as.numeric(data$married) - 1
data$frequent_church <- as.numeric(data$frequent_church) - 1
data$pid3 <- ifelse(data$democrat==1,0,ifelse(data$republican==1,2,ifelse(data$pid7=="Independent",1,NA)))
data$ideo7 <- as.numeric(data$ideo7)
data$high_incidence <- as.numeric(data$high_incidence) - 1
data$lives_highincidence <- as.numeric(data$lives_highincidence) - 1
data$nonwhite <- as.numeric(data$nonwhite) - 1
data$polinterest <- as.numeric(data$polinterest)
data$factcheck_treatment <- as.numeric(data$factcheck_treatment) - 1
data$W3factcheck_treatment <- as.numeric(data$W3factcheck_treatment) -1
data$approve_trmp <- as.numeric(data$approve_trmp) - 1
data$conspiracy <- data$conspiracy-1
data$health_trust <- data$health_trust-1
data$media_trust <- data$media_trust-1
data$therm_trump <- data$therm_trump/100

# Clean DVs
data$wear_mask <- 6-(data$wear_mask) ## It was reverse-coded
data$mask_effective <- as.numeric(data$mask_effective)
## Note: with affective polarization, the party affect variables are actually mislabeled
data$affective_polarization <- ifelse(data$pid3==0,data$feeling_Rep-data$feeling_Dem,ifelse(data$pid3==2,data$feeling_Dem-data$feeling_Rep,NA))

# Clean Treatment
data$american_treatment <- ifelse(data$exposure_treat=="Americans",1,0)
data$copartisan_treatment <- ifelse((data$pid3==0 & data$exposure_treat=="Democrats") | (data$pid3==2 & data$exposure_treat=="Republicans"),1,0)
data$contrapartisan_treatment <- ifelse((data$pid3==0 & data$exposure_treat=="Republicans") | (data$pid3==2 & data$exposure_treat=="Democrats"),1,0)

# Create underestimation/overestimation in mask wearing
data$mask_allthetime <- ifelse(data$W2_covid19_actions_2=="Most of the time" | data$W2_covid19_actions_2=="All of the time",1,0)
data$underestimates_masks_american <- ifelse(data$wear_mask_pub<65,1,0)
data$overestimates_masks_american <- ifelse(data$wear_mask_pub>=84,1,0)
data$underestimates_masks_copartisans <- ifelse(data$pid3==2 & data$wear_mask_Rep<47,1,ifelse(data$pid3==0 & data$wear_mask_Dem<80,1,ifelse(data$pid3==1,NA,0)))
data$overestimates_masks_copartisans <- ifelse(data$pid3==2 & data$wear_mask_Rep>65,1,ifelse(data$pid3==0 & data$wear_mask_Dem>98,1,ifelse(data$pid3==1,NA,0)))
data$underestimates_masks_contrapartisans <- ifelse(data$pid3==0 & data$wear_mask_Rep<47,1,ifelse(data$pid3==2 & data$wear_mask_Dem<80,1,ifelse(data$pid3==1,NA,0)))
data$overestimates_masks_contrapartisans <- ifelse(data$pid3==0 & data$wear_mask_Rep>65,1,ifelse(data$pid3==2 & data$wear_mask_Dem>98,1,ifelse(data$pid3==1,NA,0))) ## Note: It's impossible to overestimate Democrat mask wearing by 10%
data$underestimates_masks_republicans <- ifelse(data$wear_mask_Rep<47,1,0)
data$overestimates_masks_republicans <- ifelse(data$wear_mask_Rep>65,1,0)
data$underestimates_masks_democrats <- ifelse(data$wear_mask_Dem<80,1,0)
data$overestimates_masks_democrats <- ifelse(data$wear_mask_Dem>98,1,0)

# Lasso Regression
df <- data
wear_lasso <- run_LASSO(df,wear_mask) ## male, pid3, ideo7, health_trust
effective_lasso <- run_LASSO(df,mask_effective) ## pid3, ideo7, health_trust, media_trust
polariz_lasso <- run_LASSO(df,affective_polarization) ## ideo7, polinterest

# CODE
# Table 1
## Report Regularly Wearing Masks
weighted.mean(data$mask_allthetime,w=data$weight_genpop_pulse_high_inciden,na.rm=T) ## 79.54% of Americans
weighted.mean(subset(data,pid3==0)$mask_allthetime,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T) ## 93.14% of Democrats
weighted.mean(subset(data,pid3==2)$mask_allthetime,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T) ## 60.11% of Republicans
## Estimates of American Mask-Wearing
weighted.mean(data$wear_mask_pub,data$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(subset(data,pid3==0)$wear_mask_pub,subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(subset(data,pid3==2)$wear_mask_pub,subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)
## Estimates of Democrat Mask-Wearing
weighted.mean(data$wear_mask_Dem,data$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(subset(data,pid3==0)$wear_mask_Dem,subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(subset(data,pid3==2)$wear_mask_Dem,subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)
## Estimates of Republican Mask-Wearing
weighted.mean(data$wear_mask_Rep,data$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(subset(data,pid3==0)$wear_mask_Rep,subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)
weighted.mean(subset(data,pid3==2)$wear_mask_Rep,subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)
## Underestimates American Mask-Wearing by 10% or More (CHECK)
weighted.mean(data$underestimates_masks_american,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==0)$underestimates_masks_american,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==2)$underestimates_masks_american,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100
## Overestimates American Mask-Wearing by 10% or More (CHECK)
weighted.mean(data$overestimates_masks_american,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==0)$overestimates_masks_american,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==2)$overestimates_masks_american,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100
## Underestimates Democratic Mask-Wearing by 10% or More (CHECK)
weighted.mean(data$underestimates_masks_democrats,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==0)$underestimates_masks_democrats,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==2)$underestimates_masks_democrats,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100
## Overestimates Democratic Mask-Wearing by 10% or More (CHECK)
weighted.mean(data$overestimates_masks_democrats,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==0)$overestimates_masks_democrats,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==2)$overestimates_masks_democrats,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100
## Underestimates Republican Mask-Wearing by 10% or More (CHECK)
weighted.mean(data$underestimates_masks_republicans,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==0)$underestimates_masks_republicans,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==2)$underestimates_masks_republicans,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100
## Overestimates Republican Mask-Wearing by 10% or More (CHECK)
weighted.mean(data$overestimates_masks_republicans,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==0)$overestimates_masks_republicans,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100
weighted.mean(subset(data,pid3==2)$overestimates_masks_republicans,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100
## Mask-Wearing Intentons
weighted.mean(data$wear_mask,w=data$weight_genpop_pulse_high_inciden)
sqrt(wtd.var(data$wear_mask,w=data$weight_genpop_pulse_high_inciden))
weighted.mean(subset(data,pid3==0)$wear_mask,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden)
sqrt(wtd.var(subset(data,pid3==0)$wear_mask,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden))
weighted.mean(subset(data,pid3==2)$wear_mask,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden)
sqrt(wtd.var(subset(data,pid3==2)$wear_mask,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden))
## Perceived Mask Effectiveness
weighted.mean(data$mask_effective,w=data$weight_genpop_pulse_high_inciden)
sqrt(wtd.var(data$mask_effective,w=data$weight_genpop_pulse_high_inciden))
weighted.mean(subset(data,pid3==0)$mask_effective,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden)
sqrt(wtd.var(subset(data,pid3==0)$mask_effective,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden))
weighted.mean(subset(data,pid3==2)$mask_effective,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden)
sqrt(wtd.var(subset(data,pid3==2)$mask_effective,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden))
## Affective Polarization
weighted.mean(data$affective_polarization,w=data$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(data$affective_polarization,w=data$weight_genpop_pulse_high_inciden))
weighted.mean(subset(data,pid3==0)$affective_polarization,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(data,pid3==0)$affective_polarization,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden))
weighted.mean(subset(data,pid3==2)$affective_polarization,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)
sqrt(wtd.var(subset(data,pid3==2)$affective_polarization,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden))

# Figure 1
## Regression
Reg.h1a.partisans <- lm_robust(wear_mask~american_treatment+copartisan_treatment+contrapartisan_treatment+male+pid3+ideo7+health_trust,data=data,subset=pid3==0 | pid3==2)
Reg.h1a.partisans.1 <- lm(wear_mask~american_treatment+copartisan_treatment+contrapartisan_treatment+male+pid3+ideo7+health_trust,data=data,subset=pid3==0 | pid3==2)
## Standardized Effect Size for American Treatment
Reg.h1a.partisans$coefficients[2]/sd(data$wear_mask,na.rm=T)
## Equivalence Tests
data$treatment <- as.factor(ifelse(data$american_treatment==1,"American",ifelse(data$copartisan_treatment==1,"Co-Partisan",ifelse(data$contrapartisan_treatment==1,"Out-Partisan","Control"))))
data.partisans <- subset(data,pid3==0 | pid3==2)
diffmeans.h1a.partisans <- data.partisans %>% group_by(treatment) %>% summarise(mean=mean(wear_mask,na.rm=T), sd=sd(wear_mask,na.rm=T), n=n())
### Control vs. Co-Partisan
TOSTtwo.raw(m1=diffmeans.h1a.partisans$mean[2],m2=diffmeans.h1a.partisans$mean[3],sd1=diffmeans.h1a.partisans$sd[2],sd2=diffmeans.h1a.partisans$sd[3],n1=diffmeans.h1a.partisans$n[2],n2=diffmeans.h1a.partisans$n[3],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F)
### Control vs. Out-Partisan
TOSTtwo.raw(m1=diffmeans.h1a.partisans$mean[2],m2=diffmeans.h1a.partisans$mean[4],sd1=diffmeans.h1a.partisans$sd[2],sd2=diffmeans.h1a.partisans$sd[4],n1=diffmeans.h1a.partisans$n[2],n2=diffmeans.h1a.partisans$n[4],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### Out-Partisan vs. American
TOSTtwo.raw(m1=diffmeans.h1a.partisans$mean[4],m2=diffmeans.h1a.partisans$mean[1],sd1=diffmeans.h1a.partisans$sd[4],sd2=diffmeans.h1a.partisans$sd[1],n1=diffmeans.h1a.partisans$n[4],n2=diffmeans.h1a.partisans$n[1],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### Out-Patisan vs. Co-Partisan
TOSTtwo.raw(m1=diffmeans.h1a.partisans$mean[4],m2=diffmeans.h1a.partisans$mean[3],sd1=diffmeans.h1a.partisans$sd[4],sd2=diffmeans.h1a.partisans$sd[3],n1=diffmeans.h1a.partisans$n[4],n2=diffmeans.h1a.partisans$n[3],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
## Comparing Effect Sizes
linearHypothesis(Reg.h1a.partisans,"american_treatment=copartisan_treatment")
linearHypothesis(Reg.h1a.partisans,"american_treatment=contrapartisan_treatment")
linearHypothesis(Reg.h1a.partisans,"copartisan_treatment=contrapartisan_treatment")
## Create Figure 1
stargazer(Reg.h1a.partisans.1,type="text",se=starprep(Reg.h1a.partisans.1)) # Verify model
Reg.h1a.partisans.strict <- confint(Reg.h1a.partisans,level=.995)
newdata1 <- data.frame(treatment=factor(c("American","Copartisan","Contrapartisan"),levels=c("Contrapartisan","Copartisan","American")),
                       effect=c(Reg.h1a.partisans$coefficients[2],Reg.h1a.partisans$coefficients[3],Reg.h1a.partisans$coefficients[4]),
                       lci=c(Reg.h1a.partisans$conf.low[2],Reg.h1a.partisans$conf.low[3],Reg.h1a.partisans$conf.low[4]),
                       uci=c(Reg.h1a.partisans$conf.high[2],Reg.h1a.partisans$conf.high[3],Reg.h1a.partisans$conf.high[4]),
                       lci_strict=c(Reg.h1a.partisans.strict[2,1],Reg.h1a.partisans.strict[3,1],Reg.h1a.partisans.strict[4,1]),
                       uci_strict=c(Reg.h1a.partisans.strict[2,2],Reg.h1a.partisans.strict[3,2],Reg.h1a.partisans.strict[4,2]))

p.h1a <- ggplot(newdata1,aes(x=treatment,y=effect)) + coord_flip() + geom_point() + geom_errorbar(aes(ymin=lci,ymax=uci),size=.8,width=0) + geom_errorbar(aes(ymin=lci_strict,ymax=uci_strict),size=.4,width=0) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="Red") + scale_x_discrete(name="Norm treatment",breaks=c("Contrapartisan","Copartisan","American"),labels=c("Out-partisan","Co-partisan","American")) + scale_y_continuous(name="Treatment effect",limits=c(-0.29,0.53))
p.h1a

# Figure 2
## Regression
Reg.h1b.partisans <- lm_robust(wear_mask~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+(copartisan_treatment*underestimates_masks_copartisans)+(copartisan_treatment*overestimates_masks_copartisans)+(contrapartisan_treatment*underestimates_masks_contrapartisans)+(contrapartisan_treatment*overestimates_masks_contrapartisans)+male+pid3+ideo7+health_trust,data=data)
summary(margins(Reg.h1b.partisans,at=list(underestimates_masks_american=1))) ## Marginal effect for underestimators
## Marginal Effects
h1b.underestimators.partisans <- summary(margins(Reg.h1b.partisans,at=list(underestimates_masks_american=1)))
h1b.underestimators.partisans.strict <- confint(margins(Reg.h1b.partisans,at=list(underestimates_masks_american=1)),level=.995)
h1b.overestimators.partisans <- summary(margins(Reg.h1b.partisans,at=list(overestimates_masks_american=1)))
h1b.overestimators.partisans.strict <- confint(margins(Reg.h1b.partisans,at=list(overestimates_masks_american=1)),level=.995)
h2b.underestimators.partisans <- summary(margins(Reg.h1b.partisans,at=list(underestimates_masks_copartisans=1)))
h2b.overestimators.partisans <- summary(margins(Reg.h1b.partisans,at=list(overestimates_masks_copartisans=1)))
h2b.underestimators.partisans.strict <- confint(margins(Reg.h1b.partisans,at=list(underestimates_masks_copartisans=1)),level=.995)
h2b.overestimators.partisans.strict <- confint(margins(Reg.h1b.partisans,at=list(overestimates_masks_copartisans=1)),level=.995)
rq1.underestimators.partisans <- summary(margins(Reg.h1b.partisans,at=list(underestimates_masks_contrapartisans=1)))
rq1.overestimators.partisans <- summary(margins(Reg.h1b.partisans,at=list(overestimates_masks_contrapartisans=1)))
rq1.underestimators.partisans.strict <- confint(margins(Reg.h1b.partisans,at=list(underestimates_masks_contrapartisans=1)),level=.995)
rq1.overestimators.partisans.strict <- confint(margins(Reg.h1b.partisans,at=list(overestimates_masks_contrapartisans=1)),level=.995)
Reg.h1b.partisans.strict <- confint(Reg.h1b.partisans,level=.995)
## Create Figure 2
newdata2 <- data.frame(estimation=factor(c("Underestimated","Accurate","Overestimated","Underestimated","Accurate","Overestimated","Underestimated","Accurate","Overestimated"),levels=c("Overestimated","Accurate","Underestimated")),
                       treatment=factor(c("American","American","American","Co-partisan","Co-partisan","Co-partisan","Out-partisan","Out-partisan","Out-partisan"),levels=c("American","Co-partisan","Out-partisan")),
                       effect=c(h1b.underestimators.partisans$AME[1],Reg.h1b.partisans$coefficients[2],h1b.overestimators.partisans$AME[1],h2b.underestimators.partisans$AME[3],Reg.h1b.partisans$coefficients[5],h2b.overestimators.partisans$AME[3],rq1.underestimators.partisans$AME[2],Reg.h1b.partisans$coefficients[8],rq1.overestimators.partisans$AME[2]),
                       lci=c(h1b.underestimators.partisans$lower[1],Reg.h1b.partisans$conf.low[2],h1b.overestimators.partisans$lower[1],h2b.underestimators.partisans$lower[3],Reg.h1b.partisans$conf.low[5],h2b.overestimators.partisans$lower[3],rq1.underestimators.partisans$lower[2],Reg.h1b.partisans$conf.low[8],rq1.overestimators.partisans$lower[2]),
                       uci=c(h1b.underestimators.partisans$upper[1],Reg.h1b.partisans$conf.high[2],h1b.overestimators.partisans$upper[1],h2b.underestimators.partisans$upper[3],Reg.h1b.partisans$conf.high[5],h2b.overestimators.partisans$upper[3],rq1.underestimators.partisans$upper[2],Reg.h1b.partisans$conf.high[8],rq1.overestimators.partisans$upper[2]),
                       lci_strict=c(h1b.underestimators.partisans.strict[1,1],Reg.h1b.partisans.strict[2,1],h1b.overestimators.partisans.strict[1,1],h2b.underestimators.partisans.strict[4,1],Reg.h1b.partisans.strict[5,1],h2b.overestimators.partisans.strict[4,1],rq1.underestimators.partisans.strict[7,1],Reg.h1b.partisans.strict[8,1],rq1.overestimators.partisans.strict[7,1]),
                       uci_strict=c(h1b.underestimators.partisans.strict[1,2],Reg.h1b.partisans.strict[2,2],h1b.overestimators.partisans.strict[1,2],h2b.underestimators.partisans.strict[4,2],Reg.h1b.partisans.strict[5,2],h2b.overestimators.partisans.strict[4,2],rq1.underestimators.partisans.strict[7,2],Reg.h1b.partisans.strict[8,2],rq1.overestimators.partisans.strict[7,2]))

p.h1b <- ggplot(newdata2,aes(x=estimation,y=effect)) + coord_flip() + geom_point() + geom_errorbar(aes(ymin=lci,ymax=uci),size=.8,width=0) + geom_errorbar(aes(ymin=lci_strict,ymax=uci_strict),size=.4,width=0) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="Red") + facet_grid(cols=vars(treatment)) + scale_y_continuous(name="Treatment effect",limits=c(-0.4,0.53)) + xlab("Prior norm estimation")


# Figure 3
## Regression
Reg.rq2.partisans <- lm_robust(mask_effective~american_treatment+copartisan_treatment+contrapartisan_treatment+pid3+ideo7+health_trust+media_trust,data=data,subset=pid3==0 | pid3==2)
Reg.rq2.partisans.1 <- lm(mask_effective~american_treatment+copartisan_treatment+contrapartisan_treatment+pid3+ideo7+health_trust+media_trust,data=data,subset=pid3==0 | pid3==2)
## Equivalence Tests
diffmeans.rq2.partisans <- data.partisans %>% group_by(treatment) %>% summarise(mean=mean(mask_effective,na.rm=T),sd=sd(mask_effective,na.rm=T),n=n()) %>% drop_na()
### Control vs. Co-Partisan
TOSTtwo.raw(m1=diffmeans.rq2.partisans$mean[2],m2=diffmeans.rq2.partisans$mean[3],sd1=diffmeans.rq2.partisans$sd[2],sd2=diffmeans.rq2.partisans$sd[3],n1=diffmeans.rq2.partisans$n[2],n2=diffmeans.rq2.partisans$n[3],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### Control vs. Out-Partisan
TOSTtwo.raw(m1=diffmeans.rq2.partisans$mean[4],m2=diffmeans.rq2.partisans$mean[3],sd1=diffmeans.rq2.partisans$sd[4],sd2=diffmeans.rq2.partisans$sd[3],n1=diffmeans.rq2.partisans$n[4],n2=diffmeans.rq2.partisans$n[3],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
## Figure
stargazer(Reg.rq2.partisans.1,type="text",se=starprep(Reg.rq2.partisans.1))
Reg.rq2.partisans.strict <- confint(Reg.rq2.partisans,level=.995)
newdata3 <- data.frame(treatment=factor(c("American","Copartisan","Contrapartisan"),levels=c("Contrapartisan","Copartisan","American")),
                       effect=c(Reg.rq2.partisans$coefficients[2],Reg.rq2.partisans$coefficients[3],Reg.rq2.partisans$coefficients[4]),
                       lci=c(Reg.rq2.partisans$conf.low[2],Reg.rq2.partisans$conf.low[3],Reg.rq2.partisans$conf.low[4]),
                       uci=c(Reg.rq2.partisans$conf.high[2],Reg.rq2.partisans$conf.high[3],Reg.rq2.partisans$conf.high[4]),
                       lci_strict=c(Reg.rq2.partisans.strict[2,1],Reg.rq2.partisans.strict[3,1],Reg.rq2.partisans.strict[4,1]),
                       uci_strict=c(Reg.rq2.partisans.strict[2,2],Reg.rq2.partisans.strict[3,2],Reg.rq2.partisans.strict[4,2]))

p.rq2 <- ggplot(newdata3,aes(x=treatment,y=effect)) + coord_flip() + geom_point() + geom_errorbar(aes(ymin=lci,ymax=uci),size=.8,width=0) + geom_errorbar(aes(ymin=lci_strict,ymax=uci_strict),size=.4,width=0) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="Red") + scale_x_discrete(name="Norm treatment",breaks=c("Contrapartisan","Copartisan","American"),labels=c("Out-partisan","Co-partisan","American")) + scale_y_continuous(name="Treatment effect",limits=c(-0.29,0.53))

# Figure 4
## Regression (Wearing)
Reg.rq3.wear <- lm_robust(wear_mask~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+male+ideo7+health_trust,data=data,subset=pid3==0 | pid3==2)
Reg.rq3.wear.strict <- confint(Reg.rq3.wear,level=.995)
rq3.rep.wear <- summary(margins(Reg.rq3.wear,at=list(republican=1)))
rq3.rep.wear.strict <- confint(margins(Reg.rq3.wear,at=list(republican=1)),level=.995)
## Standardized Effect Size for American Treatent among Republicans
Reg.rq3.wear.gop <- lm_robust(wear_mask~american_treatment+copartisan_treatment+contrapartisan_treatment+male+ideo7+health_trust,data=data,subset=pid3==2)
Reg.rq3.wear.gop$coefficients[2]/sd(subset(data,pid3==2)$wear_mask)
## Figure
### Regression for Effectiveness
Reg.rq3.effective <- lm_robust(mask_effective~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+ideo7+health_trust+media_trust,data=data,subset=pid3==0 | pid3==2)
Reg.rq3.effective.strict <- confint(Reg.rq3.effective,level=.995)
rq3.rep.effective <- summary(margins(Reg.rq3.effective,at=list(republican=1)))
rq3.rep.effective.strict <- confint(margins(Reg.rq3.effective,at=list(republican=1)),level=.995)
### Descriptives Generation
rq3.data <- subset(data,pid3==0 | pid3==2)
rq3.wear.data <- rq3.data %>% group_by(pid3,wear_mask) %>% summarise(n=n())
rq3.wear.data$prop <- c(13/1574,10/1574,46/1574,265/1574,1240/1574,59/945,101/945,141/945,261/945,383/945)
rq3.wear.data$Party <- c("Democratic","Democratic","Democratic","Democratic","Democratic","Republican","Republican","Republican","Republican","Republican")
rq3.effective.data <- rq3.data %>% group_by(pid3,mask_effective) %>% summarise(n=n())
rq3.effective.data$prop <- c(28/1574,26/1574,199/1574,1321/1574,111/945,161/945,337/945,336/945)
rq3.effective.data$Party <- c("Democratic","Democratic","Democratic","Democratic","Republican","Republican","Republican","Republican")
rq3.data$Party <- factor(ifelse(rq3.data$pid3==2,"Republican","Democrat"),levels=c("Democrat","Republican"))

p.rq3.1 <- ggplot(rq3.wear.data,aes(x=wear_mask,y=prop,group=Party,fill=Party)) + scale_fill_manual(values=c("Blue","Red")) +  geom_bar(stat="identity",position="dodge") + theme_classic() + ylab("Proportion") + scale_x_continuous(name="Mask-wearing intentions",breaks=c(1,2,3,4,5),labels=c("Not at all","","","","All the time")) + theme(legend.position="none") + ylim(0,1)

newdata4 <- data.frame(treatment=factor(c("American","Copartisan","Contrapartisan","American","Copartisan","Contrapartisan"),levels=c("Contrapartisan","Copartisan","American")),
                       Party=factor(c("Democrat","Democrat","Democrat","Republican","Republican","Republican"),levels=c("Democrat","Republican")),
                       effect_wear=c(Reg.rq3.wear$coefficients[2],Reg.rq3.wear$coefficients[4],Reg.rq3.wear$coefficients[5],rq3.rep.wear$AME[1],rq3.rep.wear$AME[3],rq3.rep.wear$AME[2]),
                       lci_wear=c(Reg.rq3.wear$conf.low[2],Reg.rq3.wear$conf.low[4],Reg.rq3.wear$conf.low[5],rq3.rep.wear$lower[1],rq3.rep.wear$lower[3],rq3.rep.wear$lower[2]),
                       uci_wear=c(Reg.rq3.wear$conf.high[2],Reg.rq3.wear$conf.high[4],Reg.rq3.wear$conf.high[5],rq3.rep.wear$upper[1],rq3.rep.wear$upper[3],rq3.rep.wear$upper[2]),
                       lci_wear_strict=c(Reg.rq3.wear.strict[2,1],Reg.rq3.wear.strict[4,1],Reg.rq3.wear.strict[5,1],rq3.rep.wear.strict[1,1],rq3.rep.wear.strict[3,1],rq3.rep.wear.strict[4,1]),
                       uci_wear_strict=c(Reg.rq3.wear.strict[2,2],Reg.rq3.wear.strict[4,2],Reg.rq3.wear.strict[5,2],rq3.rep.wear.strict[1,2],rq3.rep.wear.strict[3,2],rq3.rep.wear.strict[4,2]),
                       effect_effective=c(Reg.rq3.effective$coefficients[2],Reg.rq3.effective$coefficients[4],Reg.rq3.effective$coefficients[5],rq3.rep.effective$AME[1],rq3.rep.effective$AME[3],rq3.rep.effective$AME[2]),
                       lci_effective=c(Reg.rq3.effective$conf.low[2],Reg.rq3.effective$conf.low[4],Reg.rq3.effective$conf.low[5],rq3.rep.effective$lower[1],rq3.rep.effective$lower[3],rq3.rep.effective$lower[2]),
                       uci_effective=c(Reg.rq3.effective$conf.high[2],Reg.rq3.effective$conf.high[4],Reg.rq3.effective$conf.high[5],rq3.rep.effective$upper[1],rq3.rep.effective$upper[3],rq3.rep.effective$upper[2]),
                       lci_effective_strict=c(Reg.rq3.effective.strict[2,1],Reg.rq3.effective.strict[4,1],Reg.rq3.effective.strict[5,1],rq3.rep.effective.strict[1,1],rq3.rep.effective.strict[3,1],rq3.rep.effective.strict[4,1]),
                       uci_effective_strict=c(Reg.rq3.effective.strict[2,2],Reg.rq3.effective.strict[4,2],Reg.rq3.effective.strict[5,2],rq3.rep.effective.strict[1,2],rq3.rep.effective.strict[3,2],rq3.rep.effective.strict[4,2]))

p.rq3.3 <- ggplot(newdata4,aes(x=treatment,y=effect_wear,group=Party,color=Party)) + scale_color_manual(values=c("Blue","Red")) + coord_flip() + geom_point(position=position_dodge(0.25)) + geom_errorbar(aes(ymin=lci_wear,ymax=uci_wear),size=.8,width=0,position=position_dodge(0.25)) + geom_errorbar(aes(ymin=lci_wear_strict,ymax=uci_wear_strict),size=.4,width=0,position=position_dodge(0.25)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="Black") + theme(legend.position="none") + scale_x_discrete(name="Norm treatment",breaks=c("Contrapartisan","Copartisan","American"),labels=c("Out-partisan","Co-partisan","American")) + scale_y_continuous(name="Treatment effect",limits=c(-0.29,0.53))

p3.1 <- ggarrange(p.rq3.1,p.rq3.3,nrow=1,common.legend=T,legend="bottom")

# Table A1
a1.m1 <- lm_robust(wear_mask~american_treatment+copartisan_treatment+contrapartisan_treatment,data=data,subset=pid3==0 | pid3==2)
a1.m2 <- lm_robust(wear_mask~american_treatment+copartisan_treatment+contrapartisan_treatment+male+pid3+ideo7+health_trust,data=data,subset=pid3==0 | pid3==2)
a1.m1.1 <- lm(wear_mask~american_treatment+copartisan_treatment+contrapartisan_treatment,data=data,subset=pid3==0 | pid3==2)
a1.m2.1 <- lm(wear_mask~american_treatment+copartisan_treatment+contrapartisan_treatment+male+pid3+ideo7+health_trust,data=data,subset=pid3==0 | pid3==2)

# Table A2
data.full <- subset(data,exposure_treat=="Do not show" | exposure_treat=="Americans")
a2.m1 <- lm_robust(wear_mask~american_treatment,data=data.full)
a2.m2 <- lm_robust(wear_mask~american_treatment+male+pid3+ideo7+health_trust,data=data.full)
a2.m1.1 <- lm(wear_mask~american_treatment,data=data.full)
a2.m2.1 <- lm(wear_mask~american_treatment+male+pid3+ideo7+health_trust,data=data.full)
## Standardized Effect Size for American Treatment
a2.m2$coefficients[2]/sd(subset(data,copartisan_treatment==0 & contrapartisan_treatment==0)$wear_mask)

# Table A3
a3.m1 <- lm_robust(wear_mask~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+(copartisan_treatment*underestimates_masks_copartisans)+(copartisan_treatment*overestimates_masks_copartisans)+(contrapartisan_treatment*underestimates_masks_contrapartisans)+(contrapartisan_treatment*overestimates_masks_contrapartisans),data=data)
a3.m2 <- lm_robust(wear_mask~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+(copartisan_treatment*underestimates_masks_copartisans)+(copartisan_treatment*overestimates_masks_copartisans)+(contrapartisan_treatment*underestimates_masks_contrapartisans)+(contrapartisan_treatment*overestimates_masks_contrapartisans)+male+pid3+ideo7+health_trust,data=data)
a3.m1.1 <- lm(wear_mask~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+(copartisan_treatment*underestimates_masks_copartisans)+(copartisan_treatment*overestimates_masks_copartisans)+(contrapartisan_treatment*underestimates_masks_contrapartisans)+(contrapartisan_treatment*overestimates_masks_contrapartisans),data=data)
a3.m2.1 <- lm(wear_mask~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+(copartisan_treatment*underestimates_masks_copartisans)+(copartisan_treatment*overestimates_masks_copartisans)+(contrapartisan_treatment*underestimates_masks_contrapartisans)+(contrapartisan_treatment*overestimates_masks_contrapartisans)+male+pid3+ideo7+health_trust,data=data)

# Table A4
a4.m1 <- lm_robust(wear_mask~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american),data=data.full)
a4.m2 <- lm_robust(wear_mask~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+male+pid3+ideo7+health_trust,data=data.full)
a4.m1.1 <- lm(wear_mask~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american),data=data.full)
a4.m2.1 <- lm(wear_mask~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+male+pid3+ideo7+health_trust,data=data.full)

# Table A5
a5.m1 <- lm_robust(mask_effective~american_treatment+copartisan_treatment+contrapartisan_treatment,data=data,subset=pid3==0 | pid3==2)
a5.m2 <- lm_robust(mask_effective~american_treatment+copartisan_treatment+contrapartisan_treatment+pid3+ideo7+health_trust+media_trust,data=data,subset=pid3==0 | pid3==2)
a5.m1.1 <- lm(mask_effective~american_treatment+copartisan_treatment+contrapartisan_treatment,data=data,subset=pid3==0 | pid3==2)
a5.m2.1 <- lm(mask_effective~american_treatment+copartisan_treatment+contrapartisan_treatment+pid3+ideo7+health_trust+media_trust,data=data,subset=pid3==0 | pid3==2)

# Table A6
a6.m1 <- lm_robust(mask_effective~american_treatment,data=data.full)
a6.m2 <- lm_robust(mask_effective~american_treatment+pid3+ideo7+health_trust+media_trust,data=data.full)
a6.m1.1 <- lm(mask_effective~american_treatment,data=data.full)
a6.m2.1 <- lm(mask_effective~american_treatment+pid3+ideo7+health_trust+media_trust,data=data.full)
## Equivalence Test for American vs. Control
diffmeans.rq2.full <- data.full %>% group_by(treatment) %>% summarise(mean=mean(mask_effective,na.rm=T),sd=sd(mask_effective,na.rm=T),n=n()) %>% drop_na()
TOSTtwo.raw(m1=diffmeans.rq2.full$mean[1],m2=diffmeans.rq2.full$mean[2],sd1=diffmeans.rq2.full$sd[1],sd2=diffmeans.rq2.full$sd[2],n1=diffmeans.rq2.full$n[1],n2=diffmeans.rq2.full$n[2],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 

# Table A7
a7.m1 <- lm_robust(wear_mask~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican),data=data,subset=pid3==0 | pid3==2)
a7.m2 <- lm_robust(wear_mask~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+male+ideo7+health_trust,data=data,subset=pid3==0 | pid3==2)
a7.m3 <- lm_robust(mask_effective~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican),data=data,subset=pid3==0 | pid3==2)
a7.m4 <- lm_robust(mask_effective~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+ideo7+health_trust+media_trust,data=data,subset=pid3==0 | pid3==2)
a7.m1.1 <- lm(wear_mask~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican),data=data,subset=pid3==0 | pid3==2)
a7.m2.1 <- lm(wear_mask~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+male+ideo7+health_trust,data=data,subset=pid3==0 | pid3==2)
a7.m3.1 <- lm(mask_effective~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican),data=data,subset=pid3==0 | pid3==2)
a7.m4.1 <- lm(mask_effective~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+ideo7+health_trust+media_trust,data=data,subset=pid3==0 | pid3==2)

# Figure A1 (See code for Figure 3 for how it was created)
p.rq3.2 <- ggplot(rq3.effective.data,aes(x=mask_effective,y=prop,group=Party,fill=Party)) + scale_fill_manual(values=c("Blue","Red")) +  geom_bar(stat="identity",position="dodge") + theme_classic() + ylab("Proportion") + scale_x_continuous(name="Mask effectiveness (accuracy)",breaks=c(1,2,3,4),labels=c("Not at all","","","Very")) + theme(legend.position="none") + ylim(0,1)
p.rq3.4 <- ggplot(newdata4,aes(x=treatment,y=effect_effective,group=Party,color=Party)) + scale_color_manual(values=c("Blue","Red")) + coord_flip() + geom_point(position=position_dodge(0.25)) + geom_errorbar(aes(ymin=lci_effective,ymax=uci_effective),size=.8,width=0,position=position_dodge(0.25)) + geom_errorbar(aes(ymin=lci_effective_strict,ymax=uci_effective_strict),size=.4,width=0,position=position_dodge(0.25)) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="Black") + theme(legend.position="none") + scale_x_discrete(name="Norm treatment",breaks=c("Contrapartisan","Copartisan","American"),labels=c("Out-partisan","Co-partisan","American")) + scale_y_continuous(name="Treatment effect",limits=c(-0.29,0.53))
p3.2 <- ggarrange(p.rq3.2,p.rq3.4,nrow=1,common.legend=T,legend="bottom")

# Table A8
## Regressions
a8.m1 <- lm_robust(affective_polarization~american_treatment+copartisan_treatment+contrapartisan_treatment,data=data)
a8.m2 <- lm_robust(affective_polarization~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican),data=data)
a8.m3 <- lm_robust(affective_polarization~american_treatment+copartisan_treatment+contrapartisan_treatment+ideo7+polinterest,data=data)
a8.m4 <- lm_robust(affective_polarization~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+ideo7+polinterest,data=data)
a8.m1.1 <- lm(affective_polarization~american_treatment+copartisan_treatment+contrapartisan_treatment,data=data)
a8.m2.1 <- lm(affective_polarization~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican),data=data)
a8.m3.1 <- lm(affective_polarization~american_treatment+copartisan_treatment+contrapartisan_treatment+ideo7+polinterest,data=data)
a8.m4.1 <- lm(affective_polarization~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+ideo7+polinterest,data=data)
## Equivalence Tests
diffmeans.rq5.1 <- data.partisans %>% group_by(treatment) %>% summarise(mean=mean(affective_polarization,na.rm=T),
                                                                        sd=sd(affective_polarization,na.rm=T),
                                                                        n=n()) %>% drop_na()

diffmeans.rq5.2 <- data.partisans %>% group_by(treatment,pid3) %>% summarise(mean=mean(affective_polarization,na.rm=T),
                                                                             sd=sd(affective_polarization,na.rm=T),
                                                                             n=n()) %>% drop_na()

### American vs. Control
TOSTtwo.raw(m1=diffmeans.rq5.1$mean[1],m2=diffmeans.rq5.1$mean[3],sd1=diffmeans.rq5.1$sd[1],sd2=diffmeans.rq5.1$sd[3],n1=diffmeans.rq5.1$n[1],n2=diffmeans.rq5.1$n[3],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### Co-Partisan vs. Control
TOSTtwo.raw(m1=diffmeans.rq5.1$mean[2],m2=diffmeans.rq5.1$mean[3],sd1=diffmeans.rq5.1$sd[2],sd2=diffmeans.rq5.1$sd[3],n1=diffmeans.rq5.1$n[2],n2=diffmeans.rq5.1$n[3],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### Out-Partisan vs. Control
TOSTtwo.raw(m1=diffmeans.rq5.1$mean[4],m2=diffmeans.rq5.1$mean[3],sd1=diffmeans.rq5.1$sd[4],sd2=diffmeans.rq5.1$sd[3],n1=diffmeans.rq5.1$n[4],n2=diffmeans.rq5.1$n[3],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
## American vs. Control, Democrats
TOSTtwo.raw(m1=diffmeans.rq5.2$mean[1],m2=diffmeans.rq5.2$mean[5],sd1=diffmeans.rq5.2$sd[1],sd2=diffmeans.rq5.2$sd[5],n1=diffmeans.rq5.2$n[1],n2=diffmeans.rq5.2$n[5],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### Co-Partisan vs. Control, Democrats
TOSTtwo.raw(m1=diffmeans.rq5.2$mean[3],m2=diffmeans.rq5.2$mean[5],sd1=diffmeans.rq5.2$sd[3],sd2=diffmeans.rq5.2$sd[5],n1=diffmeans.rq5.2$n[3],n2=diffmeans.rq5.2$n[5],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### Out-Partisan vs. Control, Democrats
TOSTtwo.raw(m1=diffmeans.rq5.2$mean[7],m2=diffmeans.rq5.2$mean[5],sd1=diffmeans.rq5.2$sd[7],sd2=diffmeans.rq5.2$sd[5],n1=diffmeans.rq5.2$n[7],n2=diffmeans.rq5.2$n[5],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### American vs. Control, Republicans
TOSTtwo.raw(m1=diffmeans.rq5.2$mean[2],m2=diffmeans.rq5.2$mean[6],sd1=diffmeans.rq5.2$sd[2],sd2=diffmeans.rq5.2$sd[6],n1=diffmeans.rq5.2$n[2],n2=diffmeans.rq5.2$n[6],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### Co-Partisan vs. Control, Republicans
TOSTtwo.raw(m1=diffmeans.rq5.2$mean[4],m2=diffmeans.rq5.2$mean[6],sd1=diffmeans.rq5.2$sd[4],sd2=diffmeans.rq5.2$sd[6],n1=diffmeans.rq5.2$n[4],n2=diffmeans.rq5.2$n[6],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 
### Out-Partisan vs. Control, Republicans
TOSTtwo.raw(m1=diffmeans.rq5.2$mean[8],m2=diffmeans.rq5.2$mean[6],sd1=diffmeans.rq5.2$sd[8],sd2=diffmeans.rq5.2$sd[6],n1=diffmeans.rq5.2$n[8],n2=diffmeans.rq5.2$n[6],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F) 

# Figure A2 (based on Table A8)
Reg.rq5.basic <- lm_robust(affective_polarization~american_treatment+copartisan_treatment+contrapartisan_treatment+ideo7+polinterest,data=data)
Reg.rq5.basic.strict <- confint(Reg.rq5.basic,level=.995)
newdata6 <- data.frame(treatment=factor(c("American","Copartisan","Contrapartisan"),levels=c("Contrapartisan","Copartisan","American")),
                       effect=c(Reg.rq5.basic$coefficients[2],Reg.rq5.basic$coefficients[3],Reg.rq5.basic$coefficients[4]),
                       lci=c(Reg.rq5.basic$conf.low[2],Reg.rq5.basic$conf.low[3],Reg.rq5.basic$conf.low[4]),
                       uci=c(Reg.rq5.basic$conf.high[2],Reg.rq5.basic$conf.high[3],Reg.rq5.basic$conf.high[4]),
                       lci_strict=c(Reg.rq5.basic.strict[2,1],Reg.rq5.basic.strict[3,1],Reg.rq5.basic.strict[4,1]),
                       uci_strict=c(Reg.rq5.basic.strict[2,2],Reg.rq5.basic.strict[3,2],Reg.rq5.basic.strict[4,2]))

p.rq5 <- ggplot(newdata6,aes(x=treatment,y=effect)) + coord_flip() + geom_point() + geom_errorbar(aes(ymin=lci,ymax=uci),size=.8,width=0) + geom_errorbar(aes(ymin=lci_strict,ymax=uci_strict),size=.4,width=0) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="Red") + scale_x_discrete(name="Norm treatment",breaks=c("Contrapartisan","Copartisan","American"),labels=c("Out-partisan","Co-partisan","American")) + ylab("Treatment effect")

# Table A9
## Regressions
a9.m1 <- lm_robust(wear_mask~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment),data=data.partisans)
a9.m2 <- lm_robust(wear_mask~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+male+pid3+ideo7+health_trust,data=data.partisans)
a9.m3 <- lm_robust(mask_effective~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment),data=data.partisans)
a9.m4 <- lm_robust(mask_effective~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+pid3+ideo7+health_trust+media_trust,data=data.partisans)
a9.m1.1 <- lm(wear_mask~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment),data=data.partisans)
a9.m2.1 <- lm(wear_mask~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+male+pid3+ideo7+health_trust,data=data.partisans)
a9.m3.1 <- lm(mask_effective~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment),data=data.partisans)
a9.m4.1 <- lm(mask_effective~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+pid3+ideo7+health_trust+media_trust,data=data.partisans)
## Interaction F-tests
### Wearing
linearHypothesis(a9.m2,c("factcheck_treatment=0","W3factcheck_treatment=0","american_treatment:factcheck_treatment=0","american_treatment:W3factcheck_treatment=0","factcheck_treatment:copartisan_treatment=0","W3factcheck_treatment:copartisan_treatment=0","factcheck_treatment:contrapartisan_treatment=0","W3factcheck_treatment:contrapartisan_treatment=0"),test="F") ## p=.2782, fail to reject null
### Effectiveness
linearHypothesis(a9.m4,c("factcheck_treatment=0","W3factcheck_treatment=0","american_treatment:factcheck_treatment=0","american_treatment:W3factcheck_treatment=0","factcheck_treatment:copartisan_treatment=0","W3factcheck_treatment:copartisan_treatment=0","factcheck_treatment:contrapartisan_treatment=0","W3factcheck_treatment:contrapartisan_treatment=0"),test="F") ## p=.014, interpret coefficients
## Equivalence Tests
diffmeans.rq4.2 <- data.partisans %>% group_by(treatment,factcheck_treatment,W3factcheck_treatment) %>% summarise(mean=mean(mask_effective,na.rm=T),sd=sd(mask_effective,na.rm=T),n=n()) %>% drop_na()
diffmeans.rq4.4 <- data.partisans %>% group_by(treatment,factcheck_treatment) %>% summarise(mean=mean(mask_effective,na.rm=T),sd=sd(mask_effective,na.rm=T),n=n()) %>% drop_na()
diffmeans.rq4.6 <- data.partisans %>% group_by(treatment,W3factcheck_treatment) %>% summarise(mean=mean(mask_effective,na.rm=T),sd=sd(mask_effective,na.rm=T),n=n()) %>% drop_na()
### Control vs. American, No Fact Checks
TOSTtwo.raw(m1=diffmeans.rq4.2$mean[5],m2=diffmeans.rq4.2$mean[9],sd1=diffmeans.rq4.2$sd[5],sd2=diffmeans.rq4.2$sd[9],n1=diffmeans.rq4.2$n[5],n2=diffmeans.rq4.2$n[9],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F)
### Control vs. American, W3 Fact-Check
TOSTtwo.raw(m1=diffmeans.rq4.4$mean[4],m2=diffmeans.rq4.4$mean[6],sd1=diffmeans.rq4.4$sd[4],sd2=diffmeans.rq4.4$sd[6],n1=diffmeans.rq4.4$n[4],n2=diffmeans.rq4.4$n[6],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F)
### Control vs. American, Both Fact-Checks
TOSTtwo.raw(m1=diffmeans.rq4.6$mean[4],m2=diffmeans.rq4.6$mean[6],sd1=diffmeans.rq4.6$sd[4],sd2=diffmeans.rq4.6$sd[6],n1=diffmeans.rq4.6$n[4],n2=diffmeans.rq4.6$n[6],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F)
### Control vs. Out-Partisan, W2 Fact-Check
TOSTtwo.raw(m1=diffmeans.rq4.2$mean[13],m2=diffmeans.rq4.2$mean[9],sd1=diffmeans.rq4.2$sd[13],sd2=diffmeans.rq4.2$sd[9],n1=diffmeans.rq4.2$n[13],n2=diffmeans.rq4.2$n[9],low_eqbound=-0.1,high_eqbound=0.1,alpha=0.05,var.equal=F)

# Figure A3
## Regressions
data.partisans$w2only <- ifelse(data.partisans$factcheck_treatment==1 & data.partisans$W3factcheck_treatment==0,1,0)
data.partisans$w3only <- ifelse(data.partisans$factcheck_treatment==0 & data.partisans$W3factcheck_treatment==1,1,0)
data.partisans$both <- ifelse(data.partisans$factcheck_treatment==1 & data.partisans$W3factcheck_treatment==1,1,0)
Reg.rq4.wear <- lm_robust(wear_mask~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+male+pid3+ideo7+health_trust,data=data.partisans)
Reg.rq4.wear.strict <- confint(Reg.rq4.wear,level=.995)
Reg.rq4.effective <- lm_robust(mask_effective~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+pid3+ideo7+health_trust+media_trust,data=data.partisans)
Reg.rq4.effective.strict <- confint(Reg.rq4.effective,level=.995)
Reg.rq4.wear.allinteractions <- lm_robust(wear_mask~(american_treatment*w2only)+(american_treatment*w3only)+(american_treatment*both)+(copartisan_treatment*w2only)+(copartisan_treatment*w3only)+(copartisan_treatment*both)+(contrapartisan_treatment*w2only)+(contrapartisan_treatment*w3only)+(contrapartisan_treatment*both),data=data.partisans)
Reg.rq4.wear.allinteractions.strict <- confint(Reg.rq4.wear.allinteractions,level=.995)
Reg.rq4.effective.allinteractions <- lm_robust(mask_effective~(american_treatment*w2only)+(american_treatment*w3only)+(american_treatment*both)+(copartisan_treatment*w2only)+(copartisan_treatment*w3only)+(copartisan_treatment*both)+(contrapartisan_treatment*w2only)+(contrapartisan_treatment*w3only)+(contrapartisan_treatment*both)+pid3+ideo7+health_trust+media_trust,data=data.partisans)
Reg.rq4.effective.allinteractions.strict <- confint(Reg.rq4.effective.allinteractions,level=.995)
rq4.wear.nofactchecks <- summary(margins(Reg.rq4.wear,at=list(factcheck_treatment=0,W3factcheck_treatment=0)))
rq4.wear.w2factcheck <- summary(margins(Reg.rq4.wear,at=list(factcheck_treatment=1)))
rq4.wear.w3factcheck <- summary(margins(Reg.rq4.wear,at=list(W3factcheck_treatment=1)))
rq4.wear.bothfactcheck <- summary(margins(Reg.rq4.wear,at=list(factcheck_treatment=1,W3factcheck_treatment=1)))
rq4.wear.nofactchecks.strict <- confint(margins(Reg.rq4.wear,at=list(factcheck_treatment=0,W3factcheck_treatment=0)),level=.995)
rq4.wear.w2factcheck.strict <- confint(margins(Reg.rq4.wear,at=list(factcheck_treatment=1)),level=.995)
rq4.wear.w3factcheck.strict <- confint(margins(Reg.rq4.wear,at=list(W3factcheck_treatment=1)),level=.995)
rq4.wear.bothfactcheck.strict <- confint(margins(Reg.rq4.wear,at=list(factcheck_treatment=1,W3factcheck_treatment=1)),level=.995)
rq4.effective.nofactchecks <- summary(margins(Reg.rq4.effective,at=list(factcheck_treatment=0,W3factcheck_treatment=0)))
rq4.effective.w2factcheck <- summary(margins(Reg.rq4.effective,at=list(factcheck_treatment=1)))
rq4.effective.w3factcheck <- summary(margins(Reg.rq4.effective,at=list(W3factcheck_treatment=1)))
rq4.effective.bothfactcheck <- summary(margins(Reg.rq4.effective,at=list(factcheck_treatment=1,W3factcheck_treatment=1)))
rq4.effective.nofactchecks.strict <- confint(margins(Reg.rq4.effective,at=list(factcheck_treatment=0,W3factcheck_treatment=0)),level=.995)
rq4.effective.w2factcheck.strict <- confint(margins(Reg.rq4.effective,at=list(factcheck_treatment=1)),level=.995)
rq4.effective.w3factcheck.strict <- confint(margins(Reg.rq4.effective,at=list(W3factcheck_treatment=1)),level=.995)
rq4.effective.bothfactcheck.strict <- confint(margins(Reg.rq4.effective,at=list(factcheck_treatment=1,W3factcheck_treatment=1)),level=.995)
## Figure
newdata5 <- data.frame(treatment=factor(c("American","Copartisan","Contrapartisan","American","Copartisan","Contrapartisan","American","Copartisan","Contrapartisan","American","Copartisan","Contrapartisan"),levels=c("Contrapartisan","Copartisan","American")),
                       factcheck=factor(c("None","None","None","W2 Only","W2 Only","W2 Only","W3 Only","W3 Only","W3 Only","W2 and W3","W2 and W3","W2 and W3"),levels=c("None","W2 Only","W3 Only","W2 and W3")),
                       effect_wear=c(Reg.rq4.wear$coefficients[2],Reg.rq4.wear$coefficients[5],Reg.rq4.wear$coefficients[6],rq4.wear.w2factcheck$AME[1],rq4.wear.w2factcheck$AME[3],rq4.wear.w2factcheck$AME[2],rq4.wear.w3factcheck$AME[1],rq4.wear.w3factcheck$AME[3],rq4.wear.w3factcheck$AME[2],rq4.wear.bothfactcheck$AME[1],rq4.wear.bothfactcheck$AME[3],rq4.wear.bothfactcheck$AME[2]),
                       lci_wear=c(Reg.rq4.wear$conf.low[2],Reg.rq4.wear$conf.low[5],Reg.rq4.wear$conf.low[6],rq4.wear.w2factcheck$lower[1],rq4.wear.w2factcheck$lower[3],rq4.wear.w2factcheck$lower[2],rq4.wear.w3factcheck$lower[1],rq4.wear.w3factcheck$lower[3],rq4.wear.w3factcheck$lower[2],rq4.wear.bothfactcheck$lower[1],rq4.wear.bothfactcheck$lower[3],rq4.wear.bothfactcheck$lower[2]),
                       uci_wear=c(Reg.rq4.wear$conf.high[2],Reg.rq4.wear$conf.high[5],Reg.rq4.wear$conf.high[6],rq4.wear.w2factcheck$upper[1],rq4.wear.w2factcheck$upper[3],rq4.wear.w2factcheck$upper[2],rq4.wear.w3factcheck$upper[1],rq4.wear.w3factcheck$upper[3],rq4.wear.w3factcheck$upper[2],rq4.wear.bothfactcheck$upper[1],rq4.wear.bothfactcheck$upper[3],rq4.wear.bothfactcheck$upper[2]),
                       lci_wear_strict=c(Reg.rq4.wear.strict[2,1],Reg.rq4.wear.strict[5,1],Reg.rq4.wear.strict[6,1],rq4.wear.w2factcheck.strict[1,1],rq4.wear.w2factcheck.strict[4,1],rq4.wear.w2factcheck.strict[5,1],rq4.wear.w3factcheck.strict[1,1],rq4.wear.w3factcheck.strict[4,1],rq4.wear.w3factcheck.strict[5,1],rq4.wear.bothfactcheck.strict[1,1],rq4.wear.bothfactcheck.strict[4,1],rq4.wear.bothfactcheck.strict[5,1]),
                       uci_wear_strict=c(Reg.rq4.wear.strict[2,2],Reg.rq4.wear.strict[5,2],Reg.rq4.wear.strict[6,2],rq4.wear.w2factcheck.strict[1,2],rq4.wear.w2factcheck.strict[4,2],rq4.wear.w2factcheck.strict[5,2],rq4.wear.w3factcheck.strict[1,2],rq4.wear.w3factcheck.strict[4,2],rq4.wear.w3factcheck.strict[5,2],rq4.wear.bothfactcheck.strict[1,2],rq4.wear.bothfactcheck.strict[4,2],rq4.wear.bothfactcheck.strict[5,2]),
                       effect_effective=c(Reg.rq4.effective$coefficients[2],Reg.rq4.effective$coefficients[5],Reg.rq4.effective$coefficients[6],rq4.effective.w2factcheck$AME[1],rq4.effective.w2factcheck$AME[3],rq4.effective.w2factcheck$AME[2],rq4.effective.w3factcheck$AME[1],rq4.effective.w3factcheck$AME[3],rq4.effective.w3factcheck$AME[2],rq4.effective.bothfactcheck$AME[1],rq4.effective.bothfactcheck$AME[3],rq4.effective.bothfactcheck$AME[2]),
                       lci_effective=c(Reg.rq4.effective$conf.low[2],Reg.rq4.effective$conf.low[5],Reg.rq4.effective$conf.low[6],rq4.effective.w2factcheck$lower[1],rq4.effective.w2factcheck$lower[3],rq4.effective.w2factcheck$lower[2],rq4.effective.w3factcheck$lower[1],rq4.effective.w3factcheck$lower[3],rq4.effective.w3factcheck$lower[2],rq4.effective.bothfactcheck$lower[1],rq4.effective.bothfactcheck$lower[3],rq4.effective.bothfactcheck$lower[2]),
                       uci_effective=c(Reg.rq4.effective$conf.high[2],Reg.rq4.effective$conf.high[5],Reg.rq4.effective$conf.high[6],rq4.effective.w2factcheck$upper[1],rq4.effective.w2factcheck$upper[3],rq4.effective.w2factcheck$upper[2],rq4.effective.w3factcheck$upper[1],rq4.effective.w3factcheck$upper[3],rq4.effective.w3factcheck$upper[2],rq4.effective.bothfactcheck$upper[1],rq4.effective.bothfactcheck$upper[3],rq4.effective.bothfactcheck$upper[2]),
                       lci_effective_strict=c(Reg.rq4.effective.strict[2,1],Reg.rq4.effective.strict[5,1],Reg.rq4.effective.strict[6,1],rq4.effective.w2factcheck.strict[1,1],rq4.effective.w2factcheck.strict[4,1],rq4.effective.w2factcheck.strict[5,1],rq4.effective.w3factcheck.strict[1,1],rq4.effective.w3factcheck.strict[4,1],rq4.effective.w3factcheck.strict[5,1],rq4.effective.bothfactcheck.strict[1,1],rq4.effective.bothfactcheck.strict[4,1],rq4.effective.bothfactcheck.strict[5,1]),
                       uci_effective_strict=c(Reg.rq4.effective.strict[2,2],Reg.rq4.effective.strict[5,2],Reg.rq4.effective.strict[6,2],rq4.effective.w2factcheck.strict[1,2],rq4.effective.w2factcheck.strict[4,2],rq4.effective.w2factcheck.strict[5,2],rq4.effective.w3factcheck.strict[1,2],rq4.effective.w3factcheck.strict[4,2],rq4.effective.w3factcheck.strict[5,2],rq4.effective.bothfactcheck.strict[1,2],rq4.effective.bothfactcheck.strict[4,2],rq4.effective.bothfactcheck.strict[5,2]))

p.rq4.1 <- ggplot(newdata5,aes(x=treatment,y=effect_wear)) + coord_flip() + geom_point() + geom_errorbar(aes(ymin=lci_wear,ymax=uci_wear),size=.8,width=0) + geom_errorbar(aes(ymin=lci_wear_strict,ymax=uci_wear_strict),size=.4,width=0) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="Red") + facet_grid(rows=vars(factcheck))+ scale_x_discrete(name="Norm treatment",breaks=c("Contrapartisan","Copartisan","American"),labels=c("Out-partisan","Co-partisan","American")) + scale_y_continuous(name="Treatment effect",limits=c(-0.29,0.53)) + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Mask-wearing intentions")
p.rq4.2 <- ggplot(newdata5,aes(x=treatment,y=effect_effective)) + coord_flip() + geom_point() + geom_errorbar(aes(ymin=lci_effective,ymax=uci_effective),size=.8,width=0) + geom_errorbar(aes(ymin=lci_effective_strict,ymax=uci_effective_strict),size=.4,width=0) + theme_classic() + geom_hline(yintercept=0,linetype="dashed",color="Red") + facet_grid(rows=vars(factcheck))+ scale_x_discrete(name="Norm treatment",breaks=c("Contrapartisan","Copartisan","American"),labels=c("Out-partisan","Co-partisan","American")) + scale_y_continuous(name="Treatment effect",limits=c(-0.29,0.53)) + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Mask effectiveness")
p4.1 <- grid.arrange(p.rq4.1,p.rq4.2,nrow=1)

# Table A10
a10.m1 <- polr(as.factor(wear_mask)~american_treatment+copartisan_treatment+contrapartisan_treatment,data=data,subset=pid3==0 | pid3==2,Hess=T)
a10.m2 <- polr(as.factor(wear_mask)~american_treatment+copartisan_treatment+contrapartisan_treatment+male+pid3+ideo7+health_trust,data=data,subset=pid3==0 | pid3==2,Hess=T)

# Table A11
a11.m1 <- polr(as.factor(wear_mask)~american_treatment,data=data.full,Hess=T)
a11.m2 <- polr(as.factor(wear_mask)~american_treatment+male+pid3+ideo7+health_trust,data=data.full,Hess=T)

# Table A12
## Set Up Synthetic data
newdata.h1a.partisans <- data.frame(american_treatment=c(0,1,0,0),copartisan_treatment=c(0,0,1,0),contrapartisan_treatment=c(0,0,0,1),male=0,pid3=0.7503,ideo7=3.84,health_trust=2.275)
newdata.h1a.full <- data.frame(american_treatment=c(0,1),male=0,pid3=0.7503,ideo7=3.84,health_trust=2.275)
## Predicted Probabilities
Reg.h1a.partisans.probs <- as.data.frame(predict(a10.m2,newdata.h1a.partisans,type="probs"))
Reg.h1a.full.probs <- as.data.frame(predict(a11.m2,newdata.h1a.full,type="probs"))

# Table A13
a13.m1 <- polr(as.factor(wear_mask)~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+(copartisan_treatment*underestimates_masks_copartisans)+(copartisan_treatment*overestimates_masks_copartisans)+(contrapartisan_treatment*underestimates_masks_contrapartisans)+(contrapartisan_treatment*overestimates_masks_contrapartisans),data=data,Hess=T)
a13.m2 <- polr(as.factor(wear_mask)~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+(copartisan_treatment*underestimates_masks_copartisans)+(copartisan_treatment*overestimates_masks_copartisans)+(contrapartisan_treatment*underestimates_masks_contrapartisans)+(contrapartisan_treatment*overestimates_masks_contrapartisans)+male+pid3+ideo7+health_trust,data=data,Hess=T)

# Table A14
a14.m1 <- polr(as.factor(wear_mask)~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american),data=data.full,Hess=T)
a14.m2 <- polr(as.factor(wear_mask)~(american_treatment*underestimates_masks_american)+(american_treatment*overestimates_masks_american)+male+pid3+ideo7+health_trust,data=data.full,Hess=T)

# Table A15
## Partisans
### Prepare Synthetic Data
newdata.h1b.partisans <- data.frame(american_treatment=c(0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0),copartisan_treatment=c(0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0),contrapartisan_treatment=c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1),underestimates_masks_american=c(0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0),overestimates_masks_american=c(0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0),underestimates_masks_copartisans=c(0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0),overestimates_masks_copartisans=c(0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0),underestimates_masks_contrapartisans=c(0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0),overestimates_masks_contrapartisans=c(0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1),male=0,pid3=0.750,ideo7=3.84,health_trust=2.275)
### Predict Probabilities
Reg.h1b.partisans.probs <- as.data.frame(predict(a13.m2,newdata.h1b.partisans,type="probs"))
## Full Sample
### Prepare Synthetic Data
newdata.h1b.full <- data.frame(american_treatment=c(0,0,0,1,1,1),underestimates_masks_american=c(0,1,0,0,1,0),overestimates_masks_american=c(0,0,1,0,0,1),male=0,pid3=0.8104,ideo7=3.919,health_trust=2.222)
### Predict Probabilities
Reg.h1b.full.probs <- as.data.frame(predict(a14.m2,newdata.h1b.full,type="probs"))

# Table A16
a16.m1 <- polr(as.factor(mask_effective)~american_treatment+copartisan_treatment+contrapartisan_treatment,data=data,subset=pid3==0 | pid3==2,Hess=T)
a16.m2 <- polr(as.factor(mask_effective)~american_treatment+copartisan_treatment+contrapartisan_treatment+pid3+ideo7+health_trust+media_trust,data=data,subset=pid3==0 | pid3==2,Hess=T)

# Table A17
a17.m1 <- polr(as.factor(mask_effective)~american_treatment,data=data.full,Hess=T)
a17.m2 <- polr(as.factor(mask_effective)~american_treatment+pid3+ideo7+health_trust+media_trust,data=data.full,Hess=T)

# Table A18
## Partisans
### Prepare Synthetic Data
newdata.rq2.partisans <- data.frame(american_treatment=c(0,1,0,0),copartisan_treatment=c(0,0,1,0),contrapartisan_treatment=c(0,0,0,1),media_trust=1.949,pid3=0.7503,ideo7=3.84,health_trust=2.275)
### Predict Probabilities
Reg.rq2.partisans.probs <- as.data.frame(predict(a16.m2,newdata.rq2.partisans,type="probs"))
## Full Sample
### Prepare Synthetic Data
newdata.rq2.full <- data.frame(american_treatment=c(0,1),media_trust=1.865,pid3=0.8104,ideo7=3.919,health_trust=2.222)
### Predict Probabilities
Reg.rq2.full.probs <- as.data.frame(predict(a17.m2,newdata.rq2.full,type="probs"))

# Table A19
a19.m1 <- polr(as.factor(wear_mask)~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican),data=data,subset=pid3==0 | pid3==2,Hess=T)
a19.m2 <- polr(as.factor(wear_mask)~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+male+ideo7+health_trust,data=data,subset=pid3==0 | pid3==2,Hess=T)
a19.m3 <- polr(as.factor(mask_effective)~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican),data=data,subset=pid3==0 | pid3==2,Hess=T)
a19.m4 <- polr(as.factor(mask_effective)~(american_treatment*republican)+(copartisan_treatment*republican)+(contrapartisan_treatment*republican)+ideo7+health_trust+media_trust,data=data,subset=pid3==0 | pid3==2,Hess=T)

# Table A20
## Prepare Synthetic Data
newdata.rq3.wear <- data.frame(american_treatment=c(0,0,1,1,0,0,0,0),copartisan_treatment=c(0,0,0,0,1,1,0,0),republican=c(0,1,0,1,0,1,0,1),contrapartisan_treatment=c(0,0,0,0,0,0,1,1),male=0,pid3=0.7503,ideo7=3.84,health_trust=2.275)
## Predict Probabilities
Reg.rq3.wear.probs <- as.data.frame(predict(a19.m2,newdata.rq3.wear,type="probs"))

# Table A21
## Prepare Synthetic Data
newdata.rq3.effective <- data.frame(american_treatment=c(0,0,1,1,0,0,0,0),copartisan_treatment=c(0,0,0,0,1,1,0,0),republican=c(0,1,0,1,0,1,0,1),contrapartisan_treatment=c(0,0,0,0,0,0,1,1),media_trust=1.949,pid3=0.7503,ideo7=3.84,health_trust=2.275)
## Predict Probabilities
Reg.rq3.effective.probs <- as.data.frame(predict(a19.m4,newdata.rq3.effective,type="probs"))

# Table A22
a22.m1 <- polr(as.factor(wear_mask)~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment),data=data.partisans,Hess=T)
a22.m2 <- polr(as.factor(wear_mask)~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+male+pid3+ideo7+health_trust,data=data.partisans,Hess=T)
a22.m3 <- polr(as.factor(mask_effective)~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment),data=data.partisans,Hess=T)
a22.m4 <- polr(as.factor(mask_effective)~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+pid3+ideo7+health_trust+media_trust,data=data.partisans,Hess=T)

# Table A23
## Prepare Synthetic Data
newdata.rq4.wear <- data.frame(american_treatment=c(0,0,0,1,1,1,0,0,0,0,0,0),copartisan_treatment=c(0,0,0,0,0,0,1,1,1,0,0,0),contrapartisan_treatment=c(0,0,0,0,0,0,0,0,0,1,1,1),factcheck_treatment=c(0,1,0,0,1,0,0,1,0,0,1,0),W3factcheck_treatment=c(0,0,1,0,0,1,0,0,1,0,0,1),male=0,pid3=0.7503,ideo7=3.84,health_trust=2.275)
## Predict Probabilities
Reg.rq4.wear.ologit <- polr(as.factor(wear_mask)~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+male+pid3+ideo7+health_trust,data=data.partisans)
Reg.rq4.wear.probs <- as.data.frame(predict(Reg.rq4.wear.ologit,newdata.rq4.wear,type="probs"))

# Table A24
## Prepare Synthetic Data
newdata.rq4.effective <- data.frame(american_treatment=c(0,0,0,1,1,1,0,0,0,0,0,0),copartisan_treatment=c(0,0,0,0,0,0,1,1,1,0,0,0),contrapartisan_treatment=c(0,0,0,0,0,0,0,0,0,1,1,1),factcheck_treatment=c(0,1,0,0,1,0,0,1,0,0,1,0),W3factcheck_treatment=c(0,0,1,0,0,1,0,0,1,0,0,1),media_trust=1.949,pid3=0.7503,ideo7=3.84,health_trust=2.275)
## Predict Probabilities
Reg.rq4.effective.ologit <- polr(as.factor(mask_effective)~(american_treatment*factcheck_treatment)+(american_treatment*W3factcheck_treatment)+(copartisan_treatment*factcheck_treatment)+(copartisan_treatment*W3factcheck_treatment)+(contrapartisan_treatment*factcheck_treatment)+(contrapartisan_treatment*W3factcheck_treatment)+pid3+ideo7+health_trust+media_trust,data=data.partisans)
Reg.rq4.effective.probs <- as.data.frame(predict(Reg.rq4.effective.ologit,newdata.rq4.effective,type="probs"))

# Table A25
data$weight_constant <- 1
## University
weighted.mean(subset(data,exposure_treat=="Do not show")$college,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$college,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$college,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$college,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$college)
## Age 18-34
data$age1834 <- ifelse(data$agegroup=="Age 18-34",1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$age1834,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$age1834,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$age1834,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$age1834,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$age1834)
## Age 35-44
data$age3544 <- ifelse(data$agegroup=="Age 35-44",1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$age3544,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$age3544,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$age3544,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$age3544,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$age3544)
## Age 45-54
data$age4554 <- ifelse(data$agegroup=="Age 45-54",1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$age4554,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$age4554,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$age4554,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$age4554,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$age4554)
## Age 55-64
data$age5564 <- ifelse(data$agegroup=="Age 55-64",1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$age5564,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$age5564,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$age5564,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$age5564,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$age5564)
## Age 65+
data$age65 <- ifelse(data$agegroup=="Age 65+",1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$age65,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$age65,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$age65,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$age65,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$age65)
## Male
weighted.mean(subset(data,exposure_treat=="Do not show")$male,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$male,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$male,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$male,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$male)
## Married
weighted.mean(subset(data,exposure_treat=="Do not show")$married,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$married,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$married,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$married,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$married)
## Frequent Church Attendance
weighted.mean(subset(data,exposure_treat=="Do not show")$frequent_church,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$frequent_church,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$frequent_church,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$frequent_church,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$frequent_church)
## Northeast
data$northeast <- ifelse(data$region=="Northeast",1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$northeast,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$northeast,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$northeast,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$northeast,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$northeast)
## South
data$south <- ifelse(data$region=="South",1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$south,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$south,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$south,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$south,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$south)
## Midwest
data$midwest <- ifelse(data$region=="Midwest",1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$midwest,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$midwest,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$midwest,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$midwest,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$midwest)
## West
data$west <- ifelse(data$region=="West",1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$west,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$west,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$west,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$west,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$west)
## Democratic
weighted.mean(subset(data,exposure_treat=="Do not show")$democrat,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$democrat,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$democrat,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$democrat,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$democrat)
## Independent
data$independent <- ifelse(data$democrat==0 & data$republican==0,1,0)
weighted.mean(subset(data,exposure_treat=="Do not show")$independent,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$independent,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$independent,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$independent,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$independent)
## Republican
weighted.mean(subset(data,exposure_treat=="Do not show")$republican,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$republican,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$republican,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$republican,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$republican)
## Ideology
weighted.mean(subset(data,exposure_treat=="Do not show")$ideo7,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$ideo7,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$ideo7,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$ideo7,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
summary(aov(ideo7~exposure_treat,data=data,weight=weight_constant))
## Lives in High-Incidence Area
weighted.mean(subset(data,exposure_treat=="Do not show")$lives_highincidence,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$lives_highincidence,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$lives_highincidence,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$lives_highincidence,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$lives_highincidence)
## Cognitive Reflection Test
weighted.mean(subset(data,exposure_treat=="Do not show")$crt,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$crt,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$crt,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$crt,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
summary(aov(crt~exposure_treat,data=data,weight=weight_constant))
## Political Knowledge
weighted.mean(subset(data,exposure_treat=="Do not show")$knowledge,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$knowledge,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$knowledge,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$knowledge,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
summary(aov(knowledge~exposure_treat,data=data,weight=weight_constant))
## Non-White
weighted.mean(subset(data,exposure_treat=="Do not show")$nonwhite,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$nonwhite,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$nonwhite,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$nonwhite,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
chisq.test(data$exposure_treat,data$nonwhite)
## Political Interest
weighted.mean(subset(data,exposure_treat=="Do not show")$polinterest,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$polinterest,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$polinterest,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$polinterest,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
summary(aov(polinterest~exposure_treat,data=data,weight=weight_constant))
## Health Trust
weighted.mean(subset(data,exposure_treat=="Do not show")$health_trust,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$health_trust,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$health_trust,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$health_trust,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
summary(aov(health_trust~exposure_treat,data=data,weight=weight_constant))
## Media Trust
weighted.mean(subset(data,exposure_treat=="Do not show")$media_trust,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Americans")$media_trust,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Democrats")$media_trust,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)
weighted.mean(subset(data,exposure_treat=="Republicans")$media_trust,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)
summary(aov(media_trust~exposure_treat,data=data,weight=weight_constant))

# REPRODUCE TABLES AND FIGURES (run code above first)
## Table 1
data.frame(variable=c("Report regularly wearing masks","Estimates of American mask-wearing","Estimates of Democrat mask-wearing","Estimates of Republican mask-wearing","Underestimates American mask-wearing by 10% or more","Overestimates American mask-wearing by 10% or more","Underestimates Democratic mask-wearing by 10% or more","Overestimates Democratic mask-wearing by 10% or more","Underestimates Republican mask-wearing by 10% or more","Overestimates Republican mask-wearing by 10% or more","Mask-wearing intention","Perceived mask effectiveness","Affective polarization","N"),
                     full_sample_mean=c(weighted.mean(data$mask_allthetime,w=data$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(data$wear_mask_pub,data$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(data$wear_mask_Dem,data$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(data$wear_mask_Rep,data$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(data$underestimates_masks_american,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(data$overestimates_masks_american,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(data$underestimates_masks_democrats,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(data$overestimates_masks_democrats,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100 ,weighted.mean(data$underestimates_masks_republicans,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(data$overestimates_masks_republicans,w=data$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(data$wear_mask,w=data$weight_genpop_pulse_high_inciden), weighted.mean(data$mask_effective,w=data$weight_genpop_pulse_high_inciden), weighted.mean(data$affective_polarization,w=data$weight_genpop_pulse_high_inciden,na.rm=T), 2982),
                     full_sample_sd=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,sqrt(wtd.var(data$wear_mask,w=data$weight_genpop_pulse_high_inciden)),sqrt(wtd.var(data$mask_effective,w=data$weight_genpop_pulse_high_inciden)),sqrt(wtd.var(data$affective_polarization,w=data$weight_genpop_pulse_high_inciden)),NA),
                     democrats_mean=c(weighted.mean(subset(data,pid3==0)$mask_allthetime,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(subset(data,pid3==0)$mask_allthetime,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(subset(data,pid3==0)$wear_mask_Dem,subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(subset(data,pid3==0)$wear_mask_Rep,subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(subset(data,pid3==0)$underestimates_masks_american,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==0)$overestimates_masks_american,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==0)$underestimates_masks_democrats,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==0)$overestimates_masks_democrats,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==0)$underestimates_masks_republicans,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==0)$overestimates_masks_republicans,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==0)$wear_mask,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden),weighted.mean(subset(data,pid3==0)$mask_effective,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden), weighted.mean(subset(data,pid3==0)$affective_polarization,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden,na.rm=T),1574),
                     democrats_sd=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,sqrt(wtd.var(subset(data,pid3==0)$wear_mask,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden)), sqrt(wtd.var(subset(data,pid3==0)$mask_effective,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden)), sqrt(wtd.var(subset(data,pid3==0)$affective_polarization,w=subset(data,pid3==0)$weight_genpop_pulse_high_inciden)),NA),
                     republicans_mean=c(weighted.mean(subset(data,pid3==2)$mask_allthetime,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(subset(data,pid3==2)$mask_allthetime,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(subset(data,pid3==2)$wear_mask_Dem,subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(subset(data,pid3==2)$wear_mask_Rep,subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T), weighted.mean(subset(data,pid3==2)$underestimates_masks_american,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==2)$overestimates_masks_american,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==2)$underestimates_masks_democrats,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==2)$overestimates_masks_democrats,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==2)$underestimates_masks_republicans,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==2)$overestimates_masks_republicans,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T)*100, weighted.mean(subset(data,pid3==2)$wear_mask,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden), weighted.mean(subset(data,pid3==2)$mask_effective,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden), weighted.mean(subset(data,pid3==2)$affective_polarization,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden,na.rm=T),945),
                     republican_sd=c(NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,sqrt(wtd.var(subset(data,pid3==2)$wear_mask,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden)), sqrt(wtd.var(subset(data,pid3==2)$mask_effective,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden)), sqrt(wtd.var(subset(data,pid3==2)$affective_polarization,w=subset(data,pid3==2)$weight_genpop_pulse_high_inciden)),NA))
## Figure 1
p.h1a
## Figure 2
p.h1b
## Figure 3
p.rq2
## Figure 4
ggarrange(p.rq3.1,p.rq3.3,nrow=1,common.legend=T,legend="bottom")
## Table A1
stargazer(a1.m1.1,a1.m2.1,type="text",se=starprep(a1.m1.1,a1.m2.1),omit.stat=c("ser","f","adj.rsq"))
## Table A2
stargazer(a2.m1.1,a2.m2.1,type="text",se=starprep(a2.m1.1,a2.m2.1),omit.stat=c("ser","f","adj.rsq"))
## Table A3
stargazer(a3.m1.1,a3.m2.1,type="text",se=starprep(a3.m1.1,a3.m2.1),omit.stat=c("ser","f","adj.rsq"),order=c(1,4,7,2,5,8,3,6,9,14,16,18,15,17,19,10,11,12,13))
## Table A4
stargazer(a4.m1.1,a4.m2.1,type="text",se=starprep(a4.m1.1,a4.m2.1),omit.stat=c("ser","f","adj.rsq"),order=c(1,2,3,8,9,4,5,6,7))
## Table A5
stargazer(a5.m1.1,a5.m2.1,type="text",se=starprep(a5.m1.1,a5.m2.1),omit.stat=c("ser","f","adj.rsq"))
## Table A6
stargazer(a6.m1.1,a6.m2.1,type="text",se=starprep(a6.m1.1,a6.m2.1),omit.stat=c("ser","f","adj.rsq"))
## Table A7
stargazer(a7.m1.1,a7.m2.1,a7.m3.1,a7.m4.1,type="text",se=starprep(a7.m1.1,a7.m2.1,a7.m3.1,a7.m4.1),omit.stat=c("ser","f","adj.rsq"),order=c(1,3,4,2,9,10,11,5,6,7,8))
## Figure A1
ggarrange(p.rq3.2,p.rq3.4,nrow=1,common.legend=T,legend="bottom")
## Table A8
stargazer(a8.m1.1,a8.m2.1,a8.m3.1,a8.m4.1,type="text",se=starprep(a8.m1.1,a8.m2.1,a8.m3.1,a8.m4.1),omit.stat=c("ser","f","adj.rsq"),order=c(1,4,2,3,5,6,7,8,9))
## Figure A2
p.rq5
## Table A9
stargazer(a9.m1.1,a9.m2.1,a9.m3.1,a9.m4.1,type="text",se=starprep(a9.m1.1,a9.m2.1,a9.m3.1,a9.m4.1),omit.stat=c("ser","f","adj.rsq"),order=c(1,4,5,2,3,11,13,15,12,14,16))
## Figure A3
grid.arrange(p.rq4.1,p.rq4.2,nrow=1)
## Table A10
stargazer(a10.m1,a10.m2,type="text")
## Table A11
stargazer(a11.m1,a11.m2,type="text")
## Table A12
data.frame(label=c("Partisans, Control","Partisans, American Treatment","Partisans, Co-Partisan Treatment","Partisans, Out-Partisan Treatment","Full, Control","Full, American Treatment"),
                        not_at_all=c(Reg.h1a.partisans.probs$`1`,Reg.h1a.full.probs$`1`),
                        not_very_often=c(Reg.h1a.partisans.probs$`2`,Reg.h1a.full.probs$`2`),
                        some_of_the_time=c(Reg.h1a.partisans.probs$`3`,Reg.h1a.full.probs$`3`),
                        most_of_the_time=c(Reg.h1a.partisans.probs$`4`,Reg.h1a.full.probs$`4`),
                        all_of_the_time=c(Reg.h1a.partisans.probs$`5`,Reg.h1a.full.probs$`5`))
## Table A13
stargazer(a13.m1,a13.m2,type="text",order=c(1,4,7,2,5,8,3,6,9,14,16,18,15,17,19,10,11,12,13))
## Table A14
stargazer(a14.m1,a14.m2,type="text",order=c(1,2,3,8,9,4,5,6,7))
## Table A15
data.frame(label=c("Partisans, Control, Accurate", "Partisans, Control, Underestimated American", "Partisans, Control, Overestimated American", "Partisans, Control, Underestimated Co-Partisan", "Partisans, Control, Overestimated Co-Partisan", "Partisans, Control, Underestimated Out-Partisan", "Partisans, Control, Overestimated Out-Partisan", "Partisans, American Treatment, Accurate", "Partisans, American Treatment, Underestimated", "Partisans, American Treatment, Overestimated", "Partisans, Co-Partisan Treatment, Accurate", "Partisans, Co-Partisan Treatment, Underestimated", "Partisans, Co-Partisan Treatment, Overestimated", "Partisans, Out-Partisan Treatment, Accurate", "Partisans, Out-Partisan Treatment, Underestimated", "Partisans, Out-Partisan Treatment, Overestimated", "Full, Control, Accurate American", "Full, Control, Underestimated American", "Full, Control, Overestimated American", "Full, American Treatment, Accurate American", "Full, American Treatment, Underestimated American", "Full, American Treatment, Overestimated American"),
           not_at_all=c(Reg.h1b.partisans.probs$`1`[c(1:3,5:6,8:18)],Reg.h1b.full.probs$`1`),
           not_very_often=c(Reg.h1b.partisans.probs$`2`[c(1:3,5:6,8:18)],Reg.h1b.full.probs$`2`),
           some_of_the_time=c(Reg.h1b.partisans.probs$`3`[c(1:3,5:6,8:18)],Reg.h1b.full.probs$`3`),
           most_of_the_time=c(Reg.h1b.partisans.probs$`4`[c(1:3,5:6,8:18)],Reg.h1b.full.probs$`4`),
           all_of_the_time=c(Reg.h1b.partisans.probs$`5`[c(1:3,5:6,8:18)],Reg.h1b.full.probs$`5`))
## Table A16
stargazer(a16.m1,a16.m2,type="text")
## Table A17
stargazer(a17.m1,a17.m2,type="text")
## Table A18
data.frame(label=c("Partisans, Control","Partisans, American Treatment","Partisans, Co-Partisan Treatment","Partisnas, Out-Partisan Treatment","Full, Control","Full, American Treatment"),
           not_at_all=c(Reg.rq2.partisans.probs$`1`,Reg.rq2.full.probs$`1`),
           not_very=c(Reg.rq2.partisans.probs$`2`,Reg.rq2.full.probs$`2`),
           somewhat=c(Reg.rq2.partisans.probs$`3`,Reg.rq2.full.probs$`3`),
           very=c(Reg.rq2.partisans.probs$`4`,Reg.rq2.full.probs$`4`))
## Table A19
stargazer(a19.m1,a19.m2,a19.m3,a19.m4,type="text",order=c(1,3,4,2,9,10,11,5,6,7,8))
## Table A20
data.frame(label=c("Control, Democrats","Control, Republicans","American Treatment, Democrats","American Treatment, Republicans","Co-Partisan Treatment, Democrats","Co-Partisan Treatment, Republicans","Out-Partisan Treatment, Democrats","Out-Partisan Treatment, Republicans"),
           not_at_all=Reg.rq3.wear.probs$`1`,
           not_very=Reg.rq3.wear.probs$`2`,
           some_of_the_time=Reg.rq3.wear.probs$`3`,
           most_of_the_time=Reg.rq3.wear.probs$`4`,
           all_of_the_time=Reg.rq3.wear.probs$`5`)
## Table A21
data.frame(label=c("Control, Democrats","Control, Republicans","American Treatment, Democrats","American Treatment, Republicans","Co-Partisan Treatment, Democrats","Co-Partisan Treatment, Republicans","Out-Partisan Treatment, Democrats","Out-Partisan Treatment, Republicans"),
           not_at_all=Reg.rq3.effective.probs$`1`,
           not_very=Reg.rq3.effective.probs$`2`,
           somewhat=Reg.rq3.effective.probs$`3`,
           very=Reg.rq3.effective.probs$`4`)
## Table A22
stargazer(a22.m1,a22.m2,a22.m3,a22.m4,type="text",order=c(1,4,5,2,3,11,13,15,12,14,16,6,7,8,9,10))
## Table A23
data.frame(label=c("Control, No FC","Control, W2 FC","Control, W3 FC","American Treatment, No FC","American Treatment, W2 FC","American Treatment, W3 FC","Co-Partisan Treatment, No FC","Co-Partisan Treatment, W2 FC","Co-Partisan Treatment, W3 FC","Out-Partisan Treatment, No FC","Out-Partisan Treatment, W2 FC","Out-Partisan Treatment, W3 FC"),
           not_at_all=Reg.rq4.wear.probs$`1`,
           not_very=Reg.rq4.wear.probs$`2`,
           some_of_the_time=Reg.rq4.wear.probs$`3`,
           most_of_the_time=Reg.rq4.wear.probs$`4`,
           all_of_the_time=Reg.rq4.wear.probs$`5`)
## Table A24
data.frame(label=c("Control, No FC","Control, W2 FC","Control, W3 FC","American Treatment, No FC","American Treatment, W2 FC","American Treatment, W3 FC","Co-Partisan Treatment, No FC","Co-Partisan Treatment, W2 FC","Co-Partisan Treatment, W3 FC","Out-Partisan Treatment, No FC","Out-Partisan Treatment, W2 FC","Out-Partisan Treatment, W3 FC"),
           not_at_all=Reg.rq4.effective.probs$`1`,
           not_very=Reg.rq4.effective.probs$`2`,
           somewhat=Reg.rq4.effective.probs$`3`,
           very=Reg.rq4.effective.probs$`4`)
## Table A25
data.frame(label=c("University","Age 18-34","Age 35-44","Age 45-54","Age 55-64", "Age 65+","Male","Married","Frequentc church attendance","Northeast","South","Midwest","West","Democratic","Independent","Republican","Conservatism","High-incidence area","Cognitive Reflection Test","Political knowledge","Non-white","Politicla interest","Health trust","Media trust"),
           control=c(weighted.mean(subset(data,exposure_treat=="Do not show")$college,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$age1834,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$age3544,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$age4554,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$age5564,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$age65,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$male,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$married,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$frequent_church,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$northeast,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$south,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$midwest,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$west,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$democrat,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$independent,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$republican,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$ideo7,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$lives_highincidence,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$crt,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$knowledge,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$nonwhite,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$polinterest,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$health_trust,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Do not show")$media_trust,subset(data,exposure_treat=="Do not show")$weight_constant,na.rm=T)),
           american=c(weighted.mean(subset(data,exposure_treat=="Americans")$college,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$age1834,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$age3544,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$age4554,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$age5564,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$age65,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$male,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$married,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$frequent_church,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$northeast,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$south,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$midwest,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$west,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$democrat,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$independent,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$republican,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$ideo7,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$lives_highincidence,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$crt,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$knowledge,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$nonwhite,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$polinterest,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$health_trust,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Americans")$media_trust,subset(data,exposure_treat=="Americans")$weight_constant,na.rm=T)),
           democrat=c(weighted.mean(subset(data,exposure_treat=="Democrats")$college,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$age1834,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$age3544,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$age4554,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$age5564,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$age65,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$male,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$married,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$frequent_church,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$northeast,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$south,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$midwest,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$west,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$democrat,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$independent,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$republican,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$ideo7,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$lives_highincidence,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$crt,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$knowledge,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$nonwhite,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$polinterest,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$health_trust,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Democrats")$media_trust,subset(data,exposure_treat=="Democrats")$weight_constant,na.rm=T)),
           republican=c(weighted.mean(subset(data,exposure_treat=="Republicans")$college,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$age1834,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$age3544,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$age4554,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$age5564,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$age65,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$male,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$married,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$frequent_church,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$northeast,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$south,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$midwest,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$west,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$democrat,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$independent,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$republican,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$ideo7,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$lives_highincidence,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$crt,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$knowledge,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$nonwhite,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$polinterest,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$health_trust,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T), weighted.mean(subset(data,exposure_treat=="Republicans")$media_trust,subset(data,exposure_treat=="Republicans")$weight_constant,na.rm=T)),
           p.value=c(chisq.test(data$exposure_treat,data$college)$p.value,chisq.test(data$exposure_treat,data$age1834)$p.value,chisq.test(data$exposure_treat,data$age3544)$p.value,chisq.test(data$exposure_treat,data$age4554)$p.value,chisq.test(data$exposure_treat,data$age5564)$p.value,chisq.test(data$exposure_treat,data$age65)$p.value,chisq.test(data$exposure_treat,data$male)$p.value,chisq.test(data$exposure_treat,data$married)$p.value,chisq.test(data$exposure_treat,data$frequent_church)$p.value,chisq.test(data$exposure_treat,data$northeast)$p.value,chisq.test(data$exposure_treat,data$south)$p.value,chisq.test(data$exposure_treat,data$midwest)$p.value,chisq.test(data$exposure_treat,data$west)$p.value,chisq.test(data$exposure_treat,data$democrat)$p.value,chisq.test(data$exposure_treat,data$independent)$p.value,chisq.test(data$exposure_treat,data$republican)$p.value,summary(aov(ideo7~exposure_treat,data=data,weight=weight_constant))[[1]]$`Pr(>F)`[1],chisq.test(data$exposure_treat,data$lives_highincidence)$p.value,summary(aov(crt~exposure_treat,data=data,weight=weight_constant))[[1]]$`Pr(>F)`[1],summary(aov(knowledge~exposure_treat,data=data,weight=weight_constant))[[1]]$`Pr(>F)`[1],chisq.test(data$exposure_treat,data$nonwhite)$p.value,summary(aov(polinterest~exposure_treat,data=data,weight=weight_constant))[[1]]$`Pr(>F)`[1],summary(aov(health_trust~exposure_treat,data=data,weight=weight_constant))[[1]]$`Pr(>F)`[1],summary(aov(media_trust~exposure_treat,data=data,weight=weight_constant))[[1]]$`Pr(>F)`[1]))
## Table A26
data$wear_mask_copartisans <- ifelse(data$pid3==0,data$wear_mask_Dem,ifelse(data$pid3==2,data$wear_mask_Rep,NA))
data$wear_mask_outpartisans <- ifelse(data$pid3==2,data$wear_mask_Dem,ifelse(data$pid3==0,data$wear_mask_Rep,NA))
data.frame(label=c("Gender","Party ID","Ideology","Health Trust","Media Trust","Estimated American Norm","Estimated Co-Partisan Norm","Estimated Out-Partisan Norm"),
           control_num=759-c(as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$male)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$pid3)==T)[2]),as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$ideo7)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$health_trust)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$media_trust)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$wear_mask_pub)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$wear_mask_copartisans)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$wear_mask_outpartisans)==T)[2])),
           control_perc=(1-c(as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$male)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$pid3)==T)[2]),as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$ideo7)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$health_trust)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$media_trust)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$wear_mask_pub)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$wear_mask_copartisans)==T)[2]), as.numeric(summary(is.na(subset(data,exposure_treat=="Do not show")$wear_mask_outpartisans)==T)[2]))/759),
           american_num=729-c(as.numeric(summary(is.na(subset(data,american_treatment==1)$male)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$pid3)==T)[2]),as.numeric(summary(is.na(subset(data,american_treatment==1)$ideo7)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$health_trust)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$media_trust)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$wear_mask_pub)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$wear_mask_copartisans)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$wear_mask_outpartisans)==T)[2])),
           american_perc=(1-c(as.numeric(summary(is.na(subset(data,american_treatment==1)$male)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$pid3)==T)[2]),as.numeric(summary(is.na(subset(data,american_treatment==1)$ideo7)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$health_trust)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$media_trust)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$wear_mask_pub)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$wear_mask_copartisans)==T)[2]), as.numeric(summary(is.na(subset(data,american_treatment==1)$wear_mask_outpartisans)==T)[2]))/729),
           copartisan_num=615-c(as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$male)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$pid3)==T)[2]),as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$ideo7)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$health_trust)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$media_trust)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$wear_mask_pub)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$wear_mask_copartisans)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$wear_mask_outpartisans)==T)[2])),
           copartisan_perc=(1-c(as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$male)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$pid3)==T)[2]),as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$ideo7)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$health_trust)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$media_trust)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$wear_mask_pub)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$wear_mask_copartisans)==T)[2]), as.numeric(summary(is.na(subset(data,copartisan_treatment==1)$wear_mask_outpartisans)==T)[2]))/615),
           outpartisan_num=633-c(as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$male)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$pid3)==T)[2]),as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$ideo7)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$health_trust)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$media_trust)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$wear_mask_pub)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$wear_mask_copartisans)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$wear_mask_outpartisans)==T)[2])),
           outpartisan_perc=(1-c(as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$male)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$pid3)==T)[2]),as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$ideo7)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$health_trust)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$media_trust)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$wear_mask_pub)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$wear_mask_copartisans)==T)[2]), as.numeric(summary(is.na(subset(data,contrapartisan_treatment==1)$wear_mask_outpartisans)==T)[2]))/633))
